<template>
  <div>
    <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
      <el-form-item label="商户号名称" prop="merchantName">
        <el-input v-model="formData.merchantName" placeholder="请输入商户号名称" :maxlength="11" show-word-limit readonly
                  clearable prefix-icon='el-icon-mobile' :style="{width: '100%'}"></el-input>
      </el-form-item>
      <el-form-item label="余额" prop="balance">
        <el-input v-model="formData.balance" placeholder="请输入余额" readonly clearable :style="{width: '100%'}">
        </el-input>
      </el-form-item>
      <el-form-item label="充值金额" prop="topupNum">
        <el-input v-model="formData.topupNum" placeholder="请输入充值金额" clearable :style="{width: '100%'}">
        </el-input>
      </el-form-item>
      <el-form-item size="large">
        <el-button type="primary" @click="submitForm">提交</el-button>
        <el-button @click="resetForm">返回</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import {
  topup
} from "@/api/modules/merchat/merchatm/merchat";

export default {
  components: {},
  props: [],
  data() {
    return {
      formData: {
        merchantName:null,
        balance:null,
        pmid:null,
        topupNum:null,
      },
    }
  },
  computed: {},
  watch: {},
  created() {
    this.getManagementById();
  },
  mounted() {},
  methods: {
    submitForm() {
      this.$refs['elForm'].validate(valid => {
        if (!valid) return
        // TODO 提交表单
          topup(this.formData.pmid,this.formData.topupNum).then(response=>{
            alert(response.msg)
            this.$store.dispatch('tagsView/delAllViews',this.$router);
            this.$router.push("sys-merchant")
          })
      })
    },
    resetForm() {
      this.$store.dispatch('tagsView/delAllViews',this.$router);
      this.$router.push("sys-merchant")
    },
    getManagementById() {
      this.formData.merchantName = this.$route.query.data.merchantName;
      this.formData.balance = this.$route.query.data.balance;
      this.formData.pmid = this.$route.query.data.pmid;
    }
  }
}

</script>
<style>
</style>
